
#include "IdManager.h"
#include "Common/Errors.h"

using namespace ttg_internal::devices;
using namespace ttg::devices;

//-----------------
//--- IdManager ---
//-----------------

IdManager *IdManager::ref = NULL;

DeviceID IdManager::generateDeviceID()
{
	DeviceID res = cur_api_ids.size();
	cur_api_ids.push_back(0);
	return res;
}

ApiID IdManager::generateApiID(DeviceID device)
{
#ifdef TTG_DEBUG
	if (cur_api_ids.size() <= device)
		throw ttg::Error(ttg::Error::FATAL, "IdManager", "generateApiID",
						 "Required device was not registered");
#endif
	return cur_api_ids[(size_t)device]++;
}

size_t IdManager::getApiCount(DeviceID device)
{
#ifdef TTG_DEBUG
	if (cur_api_ids.size() <= device)
		throw ttg::Error(ttg::Error::FATAL, "IdManager", "getApiCount",
						 "Required device was not registered");
#endif
	return (size_t)cur_api_ids[(size_t)device];
}
